#pragma once
#include <DataCore/sim_data.h>

namespace PhysLeo
{

/**
 * velocity damping cpu module
 * f = -alpha*m*v
 */
template<typename T>
class VelocityDampingCpu
{
public:
    /**
    * empty constructor
    */
    VelocityDampingCpu() = default;

    /**
     * delete default copy constructor
     */
    VelocityDampingCpu(const VelocityDampingCpu<T>&) = delete;

    /**
     * delete default move constructor
     */
    VelocityDampingCpu(VelocityDampingCpu<T>&&) = delete;

    /**
     * delete default copy assignment function
     */
    VelocityDampingCpu<T>& operator=(const VelocityDampingCpu<T>&) = delete;

    /**
     * delete default move assignment function
     */
    VelocityDampingCpu<T>& operator=(VelocityDampingCpu<T>&&) = delete;

    /**
    * virtual destructor
    */
    virtual ~VelocityDampingCpu() = default;

    /**
    * allocate resource for fixed freedom module
    * @param simData  simulation data
    */
    virtual void allocateResource(SimData<T>& simData);

    /**
     * getter of velocity_damping_param_
     * @return velocity damping parameter
     */
    T getVelocityDampingParam() { return velocity_damping_param_; }

    /**
     * setter of velocity_damping_param_
     * @param velocity_damping_param the velocity damping parameter
     */
    void setVelocityDampingParam(T velocity_damping_param) { velocity_damping_param_ = velocity_damping_param; }

    /**
    * add velocity damping force to target force data buffer
    * @param vel  velocity data buffer
    * @param force  force data buffer
    */
    virtual void addDampingForce(std::shared_ptr<BufferData<glm::tvec3<T>>> vel, std::shared_ptr<BufferData<glm::tvec3<T>>> force);

protected:
    /**
     * the mass buffer data
     */
    std::shared_ptr<BufferData<T>> ptr_mass_;

    /**
     * damping coefficient
     */
    T velocity_damping_param_;
};

}